package com.wksc.framework.impexp.thread;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RunnableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * <p> Title(文件名): ImpExpThreadPool.java </p>
 * <p> Description(描述): 导入导出线程池</p>
 * <p> Copyright(版权): Copyright (c) 2011 </p>
 * <p> Company(公司): 成都四方信息技术有限公司 </p>
 * <p> CreateTime(生成日期)：2011-10-21上午09:23:03 </p>
 * @author wanglei
 * @version impExp_C13
 */
public class ImpExpThreadPool extends ThreadPoolExecutor {
    public ImpExpThreadPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
    }

    public static ExecutorService newFixedThreadPool(int nThreads) {
        return new ImpExpThreadPool(nThreads, nThreads,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());
    }

    /**
     * 复写原有的newTaskFor方法,返回自定义FutureTask
     * @param runnable
     * @param value
     * @param <T>
     * @return
     */
    @Override
    protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
        return new ImpExpFuture<T>(runnable, value);
    }

    /**
     * 复写原有的newTaskFor方法,返回自定义FutureTask
     * @param callable
     * @return
     */
	@Override
	protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
		return new ImpExpFuture<T>(callable);
	}
}